package dujiu.leetcode.slidingWindow.fixed_lengthSlidingWindow;

public class P1456 {
    public int maxVowels(String s, int k) {
        char[] c = s.toCharArray();
        int ans = 0;
        int left = 0;
        int vowel = 0;// 元音个数
        for (int i = 0; i < c.length; i++) {
            if (c[i] == 'a' || c[i] == 'e' || c[i] == 'i' || c[i] == 'o' || c[i] == 'u'){
                vowel++;
            }
            if (i < k-1){
                continue;
            }
            ans = Math.max(ans,vowel);
            char out = c[left++];
            if (out == 'a' || out == 'e' || out == 'i' || out == 'o' || out == 'u'){
                vowel--;
            }
        }
        return ans;
    }

    public static void main(String[] args) {
        P1456 p = new P1456();
        System.out.println(p.maxVowels("abciiidef", 3));
    }
}
